﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using FM.Events;
using FM.录音.Events;
using Microsoft.Practices.Prism.Mvvm;
using Microsoft.Practices.Prism.PubSubEvents;

namespace FM.录音.Views
{
    /// <summary>
    /// 选项窗口.xaml 的交互逻辑
    /// </summary>
    public partial class 选项窗口 : Window, IView
    {
        private bool _is退出;
        public 选项窗口( )
        {
            InitializeComponent();
        }
         
      
        private void 退出Action(object obj)
        {
            _is退出 = true;
            this.Close();
        }
         
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (_is退出) return;
            this.Visibility = Visibility.Hidden;
            e.Cancel = true;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            初始化();
        }

        private void 初始化()
        {
            var 新闻部 = 小冰.新闻部;
            新闻部.GetEvent<选项确定Event>().Subscribe(x => this.Visibility = Visibility.Hidden);
            新闻部.GetEvent<选项取消Event>().Subscribe(x => this.Visibility = Visibility.Hidden);
            新闻部.GetEvent<退出Event>().Subscribe(退出Action, true);
        }

    }
}
